package com.formatos;


import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRHtmlExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;

public class HTMLReport implements Formato {

	public File escribirReporte(JasperPrint jasperPrint, HttpServletResponse response)
			throws JRException, IOException {
		response.setContentType("text/html");
		response.setCharacterEncoding("UTF-8");
		JRExporter jRExporter = new JRHtmlExporter();
		jRExporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT,jasperPrint);
		jRExporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../image?image="); // Pendiente Funciona investigar
		jRExporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,false);
		jRExporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,false);
//		OutputStream output = response.getOutputStream();
//		jRExporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, output);
//		jRExporter.exportReport();
//		output.close();
		return Util.export(jRExporter, "html");

	}

	public Object clone() throws CloneNotSupportedException {
		return new HTMLReport();
	}

}
